import { DictType, Dict, getDictList } from "@/utils/cacheUtil";
export interface EventDetail {
	event: {
		[key: string]: {
			area: number | number[];
			probs: number | number[];
		}[];
	};
	image: string[];
	timestamp: number;
}
export const useVideo = () => {
	const videoProducts = ["airoom-ipcamera", "ipcamera", "vtcamera"];

	getDictList(DictType.AiEvent).then((dictList: Dict[]) => {
		dictList.forEach((item: Dict) => {
			state.dictMap[item.key] = item;
		});
	});
	const state = reactive({
		dictMap: {} as { [key: string]: Dict }
	});
	const getAiLabel = (info: any) => {
		let data = JSON.parse(info.value);
		let event = Object.keys(data.event);
		let type = event.map(type => state.dictMap[type]?.label);
		return type.join("，");
	};

	const getAiInfo = (value: string) => {
		return JSON.parse(value);
	};
	return { videoProducts, getAiLabel, getAiInfo, dictMap: state.dictMap };
};
